
<?
$path = '../Mkart/';
include($path."common.php");

//print_r($_REQUEST) ;
//print_r($_POST) ;
//echo "succ:".$_POST["succ"] . "<br>" ;
//echo "gwsr:".$gwsr . "<br>" ;
//echo "response_code:".$response_code . "<br>" ;
//echo "response_msg:".$response_msg . "<br>" ;
//echo "process_date:".$process_date . "<br>" ;
//echo "process_time:".$process_time . "<br>" ;
//echo "od_sob:".$od_sob . "<br>" ;
//echo "auth_code:".$auth_code . "<br>" ;
//echo "amount:".$amount . "<br>" ;
//echo "od_hoho:".$od_hoho . "<br>" ;
//echo "eci:".$eci . "<br>" ;
//echo "inspect:".$inspect . "<br>" ;
//echo "spcheck:".$spcheck . "<br>" ;

if($_POST['succ'] == 1){
$state = "Y" ;

$od_sob = trim($_POST['od_sob']) ;
$amount = $_POST['amount'] ;
$process_date = $_POST['process_date'];
$process_time = $_POST['process_time'];
$auth_code = $_POST['auth_code'];
$gwsr = $_POST['gwsr'];
$spcheck = $_POST['spcheck'];
$state = $_POST['state'];

if(empty($_POST['stast']) and empty($_POST['staed'])){
	$stast = 0 ;
	$staed = 0 ;
}

$sql_up_od = "update kart_order set 
					order_price = '$amount' , 
					order_date = '$process_date' , 
					order_time = '$process_time' , 
					order_auth = '$auth_code' , 
					order_gwsr = '$gwsr' , 
					order_spcheck = '$spcheck' , 
					order_state = '$state' ,
					order_stast = '$stast' ,
					order_staed = '$staed' 
					where order_id = '$od_sob' limit 1 
					" ;
$result_up_od = mysql_query($sql_up_od) ;

$sql_item = "select * from  order_item where order_id = '$od_sob' order by order_id" ;
$result_item = mysql_query($sql_item);
while($row_item=mysql_fetch_object($result_item)){
$item_no = $row_item->item_id;							//商品編號
$item_amount = $row_item->item_amount;						//商品購買數量

$sql_pd = "select * from  product where id = '$item_no' " ;
$result_pd = mysql_query($sql_pd);
$row_pd = mysql_fetch_object($result_pd);
$pd_count = $row_pd->pd_count; //商品庫存

$qty = $pd_count - $item_amount ;

$sql_up_item = "update product set 
					pd_count = '$qty' 
					where id = '$item_no' limit 1 
					" ;
$result_up_item = mysql_query($sql_up_item) ;
}

}else{
$state = "N" ;

$sql_up_od = "update kart_order set 
					order_price = '$amount' , 
					order_date = '$process_date' , 
					order_time = '$process_time' , 
					order_auth = '$auth_code' , 
					order_gwsr = '$gwsr' , 
					order_spcheck = '$spcheck' , 
					order_state = '$state' 
					where order_id = '$od_sob' limit 1 
					" ;
$result_up_od = mysql_query($sql_up_od) ;
}

?>